﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace eventr.View
{
    public partial class FlyThroughInfoPopup : UserControl
    {
        static readonly DependencyProperty ShowPopupProperty;

        bool visible = false;

        public event EventHandler PlayFlyThrough;
        public event EventHandler HideFlyThrough;

        public FlyThroughInfoPopup()
        {
            InitializeComponent();            
        }

        public void Show()
        {
            visible = true;
            updateStates(true);
        }

        public void Hide()
        {
            visible = false;
            updateStates(true);
        }

        void updateStates(bool trans)
        {
            if (visible)
            {
                VisualStateManager.GoToState(this, "Visible", trans);
            }
            else
            {
                VisualStateManager.GoToState(this, "Invisible", trans);
            }
        }

        private void NoThanks_Click(object sender, RoutedEventArgs e)
        {
            Hide();
            if (HideFlyThrough != null)
            {
                HideFlyThrough(this, EventArgs.Empty);
            }
        }

        private void PlayFlyThrough_Click(object sender, RoutedEventArgs e)
        {
            Hide();

            if (PlayFlyThrough != null)
            {
                PlayFlyThrough(this, EventArgs.Empty);
            }
        }

        public bool ShowPopup
        {
            get
            {
                return (bool)GetValue(ShowPopupProperty);
            }
            set
            {
                SetValue(ShowPopupProperty, value);
            }
        }

        static FlyThroughInfoPopup()
        {
            ShowPopupProperty = DependencyProperty.Register("ShowPopup", typeof(bool), typeof(FlyThroughInfoPopup), new PropertyMetadata(false, (s, e) =>
            {
                bool show = (bool)e.NewValue;
                if (show)
                {
                    (s as FlyThroughInfoPopup).Show();
                }
            }));
        }
        
    }
}
